package com.pro.controller;

import com.pro.pojo.JsUserFeedback;
import com.pro.pojo.JsonData;
import com.pro.service.JsUserFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * ClassName:JsUserFeedbackController
 * Package:com.pro.controller
 * Description: 意见反馈Controller
 *
 * @Date:2022/1/14 上午 11:44
 * @Author: WYH
 */
@RestController
@RequestMapping("/feedback")
public class JsUserFeedbackController {

    @Autowired
    private JsUserFeedbackService jsUserFeedbackService;

    /**
     * @Author WYH
     * @Description //TODO 查询所有反馈
     * @Date 上午 11:45 2022/1/14
     * @Param feedbackType,feedbackStatus,limit,page
     * @return List<JsUserFeedback>
     **/
    @RequestMapping("/getAllUserFeedBack")
    public JsonData getAllUserFeedBack(String feedbackType, String feedbackStatus, Integer limit, Integer page){
        feedbackType = feedbackType != null && feedbackType != "" ? "%"+feedbackType+"%":"%%";
        feedbackStatus = feedbackStatus != null && feedbackStatus != "" ? "%"+feedbackStatus+"%":"%%";
        List<JsUserFeedback> allUserFeedBack = jsUserFeedbackService.getAllUserFeedBack(feedbackType, feedbackStatus, limit, page);
        Integer count = jsUserFeedbackService.count(feedbackType, feedbackStatus);
        return allUserFeedBack != null ? JsonData.buildSuccess(allUserFeedBack,count) : JsonData.buildError("数据格式异常");
    }

    /**
     * @Author WYH
     * @Description //TODO 删除反馈
     * @Date 下午 3:45 2022/1/14
     * @Param feedbackId
     * @return  true | false
     **/
    @RequestMapping("/delFeebdack")
    public JsonData delFeebdack(Integer feedbackId){
        Boolean delFeebdack = jsUserFeedbackService.delFeebdack(feedbackId);
        return delFeebdack != false ? JsonData.buildSuccess(delFeebdack) : JsonData.buildError("数据格式异常");
    }

    /**
     * @Author WYH
     * @Description //TODO 审核
     * @Date 下午 8:49 2022/1/14
     * @Param jsUserFeedback
     * @return  true | false
     **/
    @RequestMapping("/UpdateFeedback")
    public JsonData UpdateFeedback(JsUserFeedback jsUserFeedback){
        Boolean updateFeedback = jsUserFeedbackService.UpdateFeedback(jsUserFeedback);
        return updateFeedback != false ? JsonData.buildSuccess(updateFeedback) : JsonData.buildError("数据格式异常");
    }

    /**
     * @Author WYH
     * @Description //TODO 查询审核详情
     * @Date 上午 10:25 2022/1/15
     * @Param feedbackId
     * @return  JsUserFeedback
     **/
    @RequestMapping("/seeFeedback")
    public JsonData seeFeedback(Integer feedbackId){
        JsUserFeedback jsUserFeedback = jsUserFeedbackService.seeFeedback(feedbackId);
        return jsUserFeedback != null ? JsonData.buildSuccess(jsUserFeedback) : JsonData.buildError("数据格式异常");
    }
}
